<template>
    <div>
      <h2>这是子应用vue2的页面</h2>
      <micro-app name='vue2Page'
                 :url='url'
                 baseroute='/vue2'
      ></micro-app>
    </div>
</template>

<script>
import microApp from '@micro-zoe/micro-app'
import _ from 'lodash'

export default {
  name: 'myPage',
  data () {
    return {
      url:process.env.VUE_APP_SUB_VUE2,
      subMsg: {
        age: 1,
        name: 'zs'
      }
    }
  },
  methods: {
    changeMsg () {
      this.subMsg.age++
      const cloneData = _.cloneDeep(this.subMsg)
      microApp.setData('myPage1', cloneData)
    },
    dataListener (data) {
      console.log('来自子应用myPage1的数据', data)
      this.subMsg.name = data.name
    }
  },
  mounted () {
    microApp.addDataListener('myPage1', this.dataListener)
  }
}
</script>

<style scoped lang="less">

</style>
